package com.anc.platform.model.platform.service.impl;

import com.anc.platform.model.platform.entity.SysMenu;
import com.anc.platform.model.platform.mapper.SysMenuMapper;
import com.anc.platform.model.platform.model.vo.MenuVO;
import com.anc.platform.model.platform.service.ISysMenuService;
import com.anc.platform.utils.TreeBuilder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author Anc
 * @since 2022-07-07
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {

    @Override
    public List<SysMenu> getAllMenuInfo() {
        LambdaQueryWrapper<SysMenu> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysMenu::getDomain, 1007);
        wrapper.eq(SysMenu::getDelFlag, 0);
        List<SysMenu> list = this.list(wrapper);
        Comparator<SysMenu> sort = Comparator.comparing(SysMenu::getCreateTime);
        List<SysMenu> sysMenus = TreeBuilder.bulidSortTrees(list, "1007", sort);
        return sysMenus;
    }
}
